from src.modules import db
from datetime import datetime

class User(db.Model):
    __tablename__ = 't_system_user'
    id = db.Column(db.String(50), primary_key = True)
    user_name = db.Column(db.String(50))
    password = db.Column(db.String(50))
    phone_number = db.Column(db.String(15))
    email = db.Column(db.String(50))
    create_time = db.Column(db.DateTime, default = lambda: datetime.now())
    resume = db.Column(db.String(500))
    photo = db.Column(db.Text)
    visit = db.Column(db.Integer)

    def to_dict(self):
        d = {i.name: getattr(self, i.name) for i in self.__table__.columns}
        return d

    @classmethod
    def from_dict(cls, data):
        return cls(**data)
